﻿using Language;
using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

namespace LargeSquareOne
{
    public partial class CustomMessageBox : MultiLanguageForm
    {
        DataTable dataTable = new DataTable();
        string strLblMessage = "";

        public CustomMessageBox(DataTable _dataTable, string _strLblMessage)
        {
            InitializeComponent();


            dataTable = _dataTable;
            strLblMessage = _strLblMessage;
        }

        private void CustomMessageBox_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = dataTable;
            lblMessage.Text = strLblMessage;
        }

        //public void SetMessage(DataTable dataTable,string strLblMessage)
        //{
        //    dataGridView1.DataSource = dataTable;
        //    lblMessage.Text = strLblMessage;
        //}

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;

        }
        private void btnNo_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
            this.Close();
        }

        private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            //自动编号，与数据无关
            Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
               e.RowBounds.Location.Y,
               dataGridView1.RowHeadersWidth - 4,
               e.RowBounds.Height);
            TextRenderer.DrawText(e.Graphics,
                  (e.RowIndex + 1).ToString(),
                   dataGridView1.RowHeadersDefaultCellStyle.Font,
                   rectangle,
                   dataGridView1.RowHeadersDefaultCellStyle.ForeColor,
                   TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
        }

        //public static void Show(DataTable dataTable, string message, string title)
        //{
        //    CustomMessageBox messageBox = new CustomMessageBox(dataTable, message);
        //    messageBox.SetMessage(dataTable,message);
        //    messageBox.Text = title;
        //    messageBox.ShowDialog();
        //}


    }
}
